package Shop01;

import java.util.Comparator;

public class ProductSorters {
    public static final Comparator<Product> BY_PRICE_ASC = Comparator.comparingDouble(Product::getPrice);

    // 按价格从高到低排序（基于BY_PRICE_ASC反转）
    public static final Comparator<Product> BY_PRICE_DESC = BY_PRICE_ASC.reversed();

    // 按库存从多到少排序
    public static final Comparator<Product> BY_STOCK_DESC = Comparator.comparingInt(Product::getStock).reversed();
}
